Except where otherwise noted, this content is Copyright (c) 2020, RTE and licensed under a CC-BY-4.0 license.

Cost and Prioritization

Welcome to the next tutorial !

We will discover why hadar use cost and how to use it.

Hadar is an adequacy optimizer, like every optimizer it needs cost to determinie the best solution. In hadar, the cost to optimize represent a kind of cost needed to perform network adequacy. Than means Hadar will always try to: - use the cheaper production - use the cheaper path inside network - if hadar can’t match consumption asked, it will turn off cheaper unavailable consumption cost

Production Prioritize

Let’s start an example with a single node, there are 3 types of productions: solar, nuclear, oil. We want to use first all solar, then switch to nuclear and use oil only as last chance. To see production prioritize, we attach a growing consumption to this node.

import numpy as np
import hadar as hd

build study

study = hd.Study(horizon=30)\
    .network()\
        .node('a')\
            .consumption(name='load',   cost=10**6, quantity=np.arange(30))\
            .production(name='solar',   cost=10,    quantity=10)\
            .production(name='nuclear', cost=100,   quantity=10)\
            .production(name='oil',     cost=1000,  quantity=10)\
    .build()

# tips: If you give just one element, hadar will extended it according horizon size and scenario size

solve study

optimizer = hd.LPOptimizer()
res = optimizer.solve(study)

instance an aggragator to analyze result

agg = hd.ResultAnalyzer(study=study, result=res)

inject aggregator inside plottting to visualize result

plot = hd.HTMLPlotting(agg=agg)
plot.network().node('a').stack()

Consumption Prioritize

Consumption is bit different. Consumption cost is a unavailabilty cost. Therefore, unlike production, Hadar must to use the highest consumption cost first.

For this example, imagine your are the futur. Hydrogen is the only energy source. You have the classic load, you need to match absolutely. Then you have car recharging consumption, has to be matched but could be stopped time to time. And you have also bitcoin mining, which could be stopped as you want.

study = hd.Study(horizon=30)\
    .network()\
        .node('a')\
            .consumption(name='load',    cost=10**6, quantity=10)\
            .consumption(name='car',     cost=10**4, quantity=10)\
            .consumption(name='bitcoin', cost=10**3, quantity=10)\
            .production(name='hydrogen', cost=10,  quantity=np.arange(30))\
    .build()
res = optimizer.solve(study)
agg = hd.ResultAnalyzer(study=study, result=res)
plot = hd.HTMLPlotting(agg=agg)
plot.network().node(node='a').stack(cons_kind='given')

Border Prioritize

As for production, border cost is a cost of use. Hadar will always select the cheapest cost at first.

For example, Belgium produces many eolien power. It’s a good new because England and France has a peek of consumption. However send energy to England by submarin cable is more expansive than send it to France by traditional line. When we modelize network, we keep this technical cost gap. Like that Hadar will firstly send energy to France and if some energy remain, it will be send to England.

study = hd.Study(horizon=2)\
    .network()\
        .node('be').production(name='eolien', cost=100, quantity=[10, 20])\
        .node('fr').consumption(name='load',  cost=10**6, quantity=10)\
        .node('uk').consumption(name='load',  cost=10**6, quantity=10)\
        .link(src='be', dest='fr', cost=10, quantity=10)\
        .link(src='be', dest='uk', cost=50, quantity=10)\
    .build()
res = optimizer.solve(study)
agg = hd.ResultAnalyzer(study=study, result=res)
plot = hd.HTMLPlotting(agg=agg,
                      node_coord={'fr': [2.33, 48.86], 'be': [4.38, 50.83], 'uk': [0, 52]})
plot.network().map(t=0, zoom=2.7)

At t=0, Belgium has not enough energy for both. Hadar will send it to France to optimize transfert cost.

plot.network().map(t=1, zoom=2.7)

At t=1, Belgium has enough energy for both.